package br.com.freelancer.modelo;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Base para os modelos 
 * @author Luis Garcia
 */
@MappedSuperclass
public abstract class ModeloBase implements Serializable {

	private static final long serialVersionUID = 1L;

	public ModeloBase(){}
	
	public ModeloBase(Long id, Date dataCriacao, Date dataModificacao,
			Boolean ativo, Boolean block) {
		super();
		this.id = id;
		this.dataCriacao = dataCriacao;
		this.dataModificacao = dataModificacao;
		this.ativo = ativo;
		this.block = block;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(updatable=false, nullable=false, name = "id")
	private Long id;
	
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="dtCriacao")
	private Date dataCriacao;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="dtModificacao")
	private Date dataModificacao;

    @Column(name="ativo")
	private Boolean ativo = true;

    @Column(name="bloquado")
	private Boolean block = false;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDataCriacao() {
		return dataCriacao;
	}

	public void setDataCriacao(Date dataCriacao) {
		this.dataCriacao = dataCriacao;
	}

	public Date getDataModificacao() {
		return dataModificacao;
	}

	public void setDataModificacao(Date dataModificacao) {
		this.dataModificacao = dataModificacao;
	}

	public Boolean getAtivo() {
		return ativo;
	}

	public void setAtivo(Boolean ativo) {
		this.ativo = ativo;
	}

	public Boolean getBlock() {
		return block;
	}

	public void setBlock(Boolean block) {
		this.block = block;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Usuario other = (Usuario) obj;
		if (this.getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!this.getId().equals(other.getId()))
			return false;
		return true;
	}
    
}